class Solution {
public:
    bool carPooling(vector<vector<int>>& trips, int capacity) {
        bool f = 0;
        vector<int>s(1010);
        int n = trips.size();
        for (auto x : trips) {
            s[x[1]] += x[0];
            s[x[2]] -= x[0];
        }
        for (int i = 0; i <= 1000; i++) {
            if (i) s[i] += s[i - 1];
            if (s[i] > capacity) {
                f = 1;
                cout << "i==" << i << endl;
                break;
            }
        }
        if (!f)return 1;
        return 0;
    }
};